package com.itown.expo.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.web.servlet.ModelAndView;

import webframe.common.helper.ControllerHelper;

import com.itown.expo.controller.base.MyBaseCommandController;
import com.itown.expo.model.UnvalidDecl;

public class UnvalidDeclListController extends MyBaseCommandController {

	@Override
	protected ModelAndView handleInner(HttpServletRequest request,
			HttpServletResponse response, Object command) {
		UnvalidDecl cUnvalidDecl = (UnvalidDecl) command;

		if (cUnvalidDecl.getUsername() != null) {
			if (cUnvalidDecl.getUsername().equals("del")) {
				getServiceContainer().getCheckBizService().deleteUnvalidDecl(
						cUnvalidDecl.getId());
			}
		}

		DetachedCriteria criteria = DetachedCriteria
				.forClass(UnvalidDecl.class);

		ControllerHelper.addLikeRestrictions(criteria, "declNo", cUnvalidDecl
				.getDeclNo());

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("page", ControllerHelper.queryPagination(request, criteria));
		map.put("cUnvalidDecl", cUnvalidDecl);
		return new ModelAndView("UnvalidDeclList.jsp", "map", map);
	}

}
